package com.xubeizhi.controller;

import com.xubeizhi.common.Result;
import com.xubeizhi.entity.Debt;
import com.xubeizhi.service.DebtService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/debt")
@RestController
@CrossOrigin
public class DebtController {

    @Autowired
    private DebtService deptService;

    @PostMapping("/create")
    private Result createDebt(@RequestBody Debt debt) {
        return deptService.CreateDept(debt);
    }

    @PutMapping("/remove")
    private Result removeDebt(@RequestBody Debt debt) {
        return deptService.deleteDept(debt);
    }

    @PutMapping("/update")
    private Result updateDebt(@RequestBody Debt debt) {
        return deptService.updateByIdDept(debt);
    }

    @GetMapping("/listdebt")
    private Result listDebt(Integer pageNum, Integer pageSize, @RequestParam(required = false) String name, @RequestParam(required = false) String status, String removeStatus) {
        return deptService.listDebt(pageNum, pageSize, name, status, removeStatus);
    }

    @GetMapping("/list")
    private Result list(Integer pageNum, Integer pageSize, Integer id, String status) {
        return deptService.list(pageNum, pageSize, id, status);
    }

    @GetMapping("/searchtime")
    private Result searchList(@RequestParam(required = false)String name,@RequestParam(required = false) String starDate, @RequestParam(required = false)String endDate) {
        return deptService.searchDebt(name, starDate, endDate);
    }
}
